package bll;

import java.util.*;
import util.*;
import model.*;

public class ApprovalBll {
	public static List<EmployeeModel> getApprovers(String objectType, int objectId) throws Exception {
		List<EmployeeModel> employees = CacheUtil.getEmployeeList();

		// TODO filter approvers by object type
		// Do it later

		return employees;
	}

	public static boolean canApprove(String objectType, int objectId) throws Exception {
		boolean canApproval = true;

		// TODO implement the business

		// chi cho phép nếu Status của đối tượng khác SUBMITTED và khác APPROVED

		return canApproval;
	}

	public static boolean submitForApprove(ApprovalModel approval) throws Exception {
		boolean succ = true;

		// TODO
		// Insert approval to DB with status = Submitted
		// Update Object status --> Submited
		// case Project
		// case Document
		// case Quotation
		// Send mail (PENDING, don't do it now)

		return succ;
	}

	public static boolean doApprove(ApprovalModel approval) throws Exception {
		boolean succ = true;

		// TODO
		// Update Approval to DB
		// Update Object status --> APPROVED or REJECT
		// case Project
		// case Document
		// case Quotation
		// Send mail (PENDING, don't do it now)
		return succ;
	}

}
